﻿using AppTemplate.Infrastructure.EntityBase;
using AppTemplate.Infrastructure.Paging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AppTemplate.Infrastructure.ServiceBase
{
    public interface IService<T> where T : class,IEntity
    {

        Task<int> Create(T entity, CancellationToken cancellationToken = default);

        Task<int> Delete(int id, CancellationToken cancellationToken = default);
        Task<int> Delete(T entity, CancellationToken cancellationToken = default);


        Task<int> Update(T entity, CancellationToken cancellationToken = default);
        Task<int> UpdateById(int id, object dataObject, CancellationToken cancellationToken = default);

        Task<T?> Get(int id, CancellationToken cancellationToken = default);
        Task<IEnumerable<T>?> GetAll(CancellationToken cancellationToken = default);
        Task<IEnumerable<T>?> GetByIds(IEnumerable<int> ids, CancellationToken cancellationToken = default);

        Task<PageSearchResult<T>> PageSearch(int pageIndex, int pageSize, Expression<Func<T, bool>>? predicate = default, CancellationToken cancellationToken = default);
    }
}
